package guitar

import (
	"context"
	"time"

	"go-weixin/app/guitar/api/internal/svc"
	"go-weixin/app/guitar/api/internal/types"
	"go-weixin/app/guitar/rpc/pb/proto/guitar"

	"github.com/zeromicro/go-zero/core/logx"
)

type GuitarUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGuitarUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GuitarUpdateLogic {
	return &GuitarUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GuitarUpdateLogic) GuitarUpdate(req *types.GuitarUpdateReq) (resp *types.GuitarUpdateResp, err error) {
	ctx, cannFunc := context.WithTimeout(context.Background(), time.Second*5)
	defer cannFunc()
	_, err = l.svcCtx.GuitarRPC.GuitarUpdate(ctx, &guitar.GuitarUpdateReq{
		Id:    req.Id,
		Title: req.Title,
	})
	resp = new(types.GuitarUpdateResp)
	return
}
